import fs from 'fs'
import path from 'path'

export default function svgInject() {
  return {
    name: 'svg-inject',
    transformIndexHtml(html) {
      const svgContent = fs.readFileSync(
        path.resolve(__dirname, '../src/assets/images/icon.svg'),
        'utf-8'
      )
      
      return html.replace(
        /<\/body>/,
        `${svgContent}</body>`
      )
    }
  }
}